﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using Domain.Dummies.Dtos;

namespace Services.Dummies.AuthorizationService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class DummyAuthorizationService : IAuthorization
    {
        #region IAuthorization Members

        public SessionDto Auth(string userName, string password, string accessObject)
        {
            var current_session = new SessionDto();
            current_session.SessionGuid = Guid.NewGuid();            
            current_session.__debug_string = "was in DummyAuthorizationService::Auth(...)";

            return current_session;  //dummy for all ok!
        }

        public bool CheckRights(SessionDto session, string accessObject)
        {            
            if (accessObject.Equals("GetStudentsWithGroups") ||
                accessObject.Equals("GetExamsByStudent")     ||
                accessObject.Equals("GetTeacherWeekSchedule")||
                accessObject.Equals("GetTeacherDaySchedule") ||
                accessObject.Equals("SearchBook")            ||
                accessObject.Equals("GetListOfBookWhichPersonGetInLibrary")
               )
               return true;
            else
                return false;
        }

        public bool AddUser(SessionDto session, string userName, string password)
        {
            return true;
        }

        public bool AttachAccessObject(SessionDto session, string userName, string accessObject)
        {
            return true;
        }

        public bool DeleteUser(SessionDto session, string userName)
        {
            return true;
        }

        public bool DetachAccessObject(SessionDto session, string userName, string accessObject)
        {
            return true;
        }

        #endregion



        //for bad times example
        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                throw new ArgumentNullException("composite");
            }
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }        
    }
}
